package dreampack.dataModify;

import java.sql.*;
import dreampack.*;

public class MonStarModify {
	public MonStarModify() { }
	
	public static int increaseScore(DreamDB dreamDb, int monstarId) throws Exception {
		int nRet = DMStatus.Ok;
		Connection con = null;
		Statement stmt = null;
		try {
			con = dreamDb.getConnection();
			String sql = "update t_ht_monthstar set score = score + 1 where id = " + monstarId;
			stmt = con.createStatement();
			int nLines = stmt.executeUpdate(sql);
			if (0 == nLines)
				nRet = DMStatus.NoUser;	//不存在 id 为 monstarId 的"明星"
		} catch (Exception e) {
			nRet = DMStatus.Failed;
		} finally {
			dreamDb.closeStatement(stmt);
			dreamDb.closeConnection(con);
		}
		return nRet;
	}
}
